

	
	package it.polimi.travelDream.web.beans;  
	  
	import javax.faces.application.FacesMessage;  
	import javax.faces.context.FacesContext;    
	import org.primefaces.model.menu.DefaultMenuItem;  
	import org.primefaces.model.menu.DefaultMenuModel;  
	import org.primefaces.model.menu.DefaultSubMenu;  
	import org.primefaces.model.menu.MenuModel;    
	
	
	public class MenuBean {  
		 private MenuModel model; 
		
		 
		 public MenuBean() {  
		        model = new DefaultMenuModel();  
		          
		        //First submenu  
		        DefaultSubMenu firstSubmenu = new DefaultSubMenu("Dynamic Submenu");  
		          
		        DefaultMenuItem item = new DefaultMenuItem("External");  
		        item.setUrl("http://www.primefaces.org");  
		        item.setIcon("ui-icon-home");  
		        firstSubmenu.addElement(item);  
		          
		        model.addElement(firstSubmenu);  
		          
		      
		    }  
		  
		 public MenuModel getModel() {  
		        return model;  
		    }     
		      
		  
		  
		    public String redirect() {  
		        return "home?faces-redirect=true";  
		    }  
		      
		  
		 
		 
		 
		 public void modify() {  
		        addMessage("modify saved"); 
	
		    }  
		
		 
		 public void search() {  
		        addMessage("Data saved");  
		    }  
		 
		
	    public void save() {  
	        addMessage("Data saved");  
	    }  
	      
	    public void update() {  
	        addMessage("Data updated");  
	    }  
	      
	    public void delete() {  
	        addMessage("Data deleted");  
	    }  
	      
	    public void addMessage(String summary) {  
	        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary,  null);  
	        FacesContext.getCurrentInstance().addMessage(null, message);  
	    }  
	}  
	  
	
	
